// pages/depoly/depoly_selectBarnPos.ts
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    barns:[],
    barnInd:0,
    positions:[],
    posInd:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    
  },
  onPickBarn(en){
    var me = this;
    try { 
      app.globalData.depolyData.barnInd =en.currentTarget.dataset.barnind;  
      console.log(app.globalData.depolyData)
      me.setData({barnInd:app.globalData.depolyData.barnInd})  

    } catch (error) {
      console.log(error);
    }
  },
  onPickPos(en){
    var me = this;
    try { 
      app.globalData.depolyData.posInd =en.currentTarget.dataset.posind;   
      me.setData({posInd:app.globalData.depolyData.posInd})  

    } catch (error) {
      console.log(error);
    }
  },
  acCancel(en){
    var me = this;
    try { 
      wx.switchTab({
        url:'./depoly'
      })

    } catch (error) {
      console.log(error);
    }
  },
  acCancel( ){
    var me = this;
    try { 
      wx.switchTab({
        url:"./depoly"
      })
    } catch (error) {
      console.log(error);
    }
  },
  acNext( ){
    var me = this;
    try { 
      wx.navigateTo({
        url:"./depoly_post"
      })
    } catch (error) {
      console.log(error);
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    var grainId = app.globalData.depolyData.grains[app.globalData.depolyData.grainInd].grainId;
    var data = {
      barns:app.globalData.depolyData.barns , 
      barnInd: app.globalData.depolyData.barnInd , 
      positions:app.globalData.depolyData.positions , 
      posInd: app.globalData.depolyData.posInd , 
      grainId:grainId
    };
    this.setData(data ,()=>{
      console.log(this.data)
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})